package com.atguigu.gmall.item.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.concurrent.*;

/**
 *
 */
@Configuration
@SuppressWarnings("all")
public class ThreadPoolConfig {


    @Bean
    public ThreadPoolExecutor executor() {

        return new ThreadPoolExecutor(
                //核心线程数或者说是常驻线程数
                50,
                //线程池中最大支持的线程数
                500,
                //线程空闲时间
                50,
                //线程空闲时间单位
                TimeUnit.SECONDS,
//                BlockingDeque 1000,
                //堵塞队列
                new ArrayBlockingQueue<>(1000),
                //线程工厂
                Executors.defaultThreadFactory(),
                //使用拒绝策略
                new ThreadPoolExecutor.AbortPolicy()

        );

    }
}
